package com.haiyangwang1.lesson11;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Locale;

public class Demo7 {
    //    定义一个函数，接收三个整型数据(年、月、日)，计算出该日期是今年的第多少天？
    public static int getDate(int year, int month, int date) {
        int[] day = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int count = 0;
        int chazhi = 0;
        for (int i = 0; i < day.length; i++) {
            if (i < month) {
                count += day[i];
                chazhi = day[i] - date;
            }
        }
        if (((year % 4 == 0) && (year % 100 != 0)) | (year % 400 == 0)) {
            if (month > 2) {
                count++;
                return count = count - chazhi;
            }
        } else {
            return count = count - chazhi;
        }
        return count;
    }
    public static void main(String[] args) {
        System.out.println(getDate(2020, 12, 31));
    }
}
